---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source: embed # can show the code
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(plotly)
library(rnoaa)
```
```{r}
weather_df =
rnoaa::meteo_pull_monitors(
c("USW00094728", "USC00519397", "USS0023B17S"),
var = c("DATE", "PRCP", "TMIN", "TMAX", "SNOW", "SNWD"),
date_min = "2017-01-01",
date_max = "2017-12-31") %>%
mutate(
name = recode(
id,
USW00094728 = "CentralPark_NY",
USC00519397 = "Waikiki_HA",
USS0023B17S = "Waterhole_WA"),
tmin = tmin / 10,
tmax = tmax / 10,
prcp = prcp / 10) %>%
select(name, id, everything())
```
Column {data-width=650}
-----------------------------------------------------------------------
### The distribution of the max and min temperature
```{r}
weather_df %>%
mutate(text_label = str_c("Max:", tmax, "\nMin:", tmin)) %>%
plot_ly(x = ~tmax, y = ~tmin, text = ~text_label, alpha = .5, color = ~name, type = "scatter", mode = "markers", colors = "viridis")
```
Column {data-width=350}
-----------------------------------------------------------------------
### The distribution of Precipitation in the three areas
```{r}
weather_df %>%
mutate(name = fct_reorder(name, prcp),
text_label = str_c(name, "\nPrecipitation: ", prcp, " mm")) %>%
plot_ly(y = ~prcp, x = ~name, color = ~name, text = ~text_label, type = "violin", colors = "viridis")
```
### The trend of the maximun temperature in 2017
```{r}
weather_df %>%
plot_ly(x = ~date, y = ~tmax, color = ~name, type = "scatter", mode = "lines", colors = "viridis")
```